<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.blockchain.console.servlets.content.cjwt.UpdateQuestionPxz"%>
<%@page import="com.blockchain.console.servlets.content.cjwt.UpdateQuestion"%>
<%@page import="com.blockchain.console.servlets.content.cjwt.DeleteQuestion"%>
<%@page import="com.blockchain.console.servlets.content.cjwt.AddQuestion"%>
<%@page import="com.blockchain.console.servlets.content.cjwt.QuestionList"%>
<%@page import="com.blockchain.console.service.content.entity.QuestionRecord"%>
<%@page import="com.blockchain.common.enums.QuestionType"%>
<html >
<head>
<%@include file="/WEB-INF/include/meta.jsp"%>
<%@include file="/WEB-INF/include/style.jsp"%>
</head>
<body>
<%
	CURRENT_CATEGORY = "NRGL";
	CURRENT_SUB_CATEGORY = "CJWT";
	
	PagingResult<QuestionRecord> result=(PagingResult<QuestionRecord>)request.getAttribute("pr");
	QuestionRecord[] records = result.getItems();
%>
<%@include file="/WEB-INF/include/header.jsp"%>
<div class="w_main">
<div class="main clearfix">
	 
	 <form action="<%=controller.getURI(request, QuestionList.class)%>" method="post">
  	 <div class="wrap">
        <div class="r_main">
            <div class="home_main">
            	<div class="box box1 mb15">
                	<div class="atil">
                    	<h3>帮助中心</h3>
                  </div>
                    <div class="con">
                    <div class="clear"></div>
                    <div class="admin_input admin_pb">
                    <p>
                    <span>问题：</span><span><input type="text" name="question" id="textfield" class="yhgl_input" value="<%StringHelper.filterHTML(out, request.getParameter("question")); %>"/></span>
                    </p>
                    <p>问题类型：
                          <select name="qt" class="yhgl_sel">
                            <option value="">请选择</option>
                           <%
                            for (QuestionType qt : QuestionType.values()) {
                           %>
						   <option value="<%=qt.name()%>" <%if (qt.name().equals(request.getParameter("qt"))) {%> selected="selected" <%}%>><%=qt.getName()%></option>
						   <%
						    }
						   %>                                
                          </select>
                    </p>
            		 <div class="clear"></div>   
                    <div class="mt10">   
                    <input name="" type="submit" class="btn2 mr10" value="搜索" style="cursor: pointer;"/>
                    <%if (blockchainSession.isAccessableResource(AddQuestion.class)) {%>
                    	<a href="<%=controller.getURI(request, AddQuestion.class)%>" class="btn3 mr10"><span class="ico3"></span>添加</a>
                    <%}else{ %>
						<span class="btn3 btn5 mr10"><span class="ico3"></span>添加</span>
					<%} %> 
                    </div>               
                    <div class="clear"></div>
                    </div>      
                  </div>
                </div>
                <div>
                  <table width="100%" border="0" cellspacing="0" cellpadding="3" class="yhgl_table tc">
                        <tr class="hsbg">
                          <td>序号</td>
                          <td>排序值</td>
                          <td>类型</td>
                          <td>问题</td>
                          <td>发布人</td>
                          <td>发布时间</td>
                          <td>操作</td>                          
                        </tr>
                        <%
							if (records != null) {int index = 1;for (QuestionRecord record : records) {
						%>
                        <tr class="dhsbg">
                          	<td><%=index++ %></td>
                          	<td style="display: none"><%=record.id%></td>
                          	<td class="setpxz"><%=record.pxz%></td>         
                          	<td><%=record.qt.getName()%></td>
                          	<td title="<%StringHelper.filterHTML(out, record.question); %>"><%StringHelper.filterHTML(out, StringHelper.truncation(record.question, 50)); %></td>
                          	<td><%StringHelper.filterHTML(out, record.name); %></td>
                          	<td><%=DateParser.format(record.tjsj) %></td>
                          	<td class="blue">
                          		<%if (blockchainSession.isAccessableResource(UpdateQuestion.class)) {%>
	                          		<a href="<%=controller.getURI(request, UpdateQuestion.class)%>?id=<%=record.id %>">修改</a>
	                          	<%}else{ %>
									<span class="gray6">修改</span>
								<%} %>
								<%if (blockchainSession.isAccessableResource(DeleteQuestion.class)) {%>   
	                          		<a href="<%=controller.getURI(request, DeleteQuestion.class)%>?id=<%=record.id %>"   onclick="return idDelete()">删除</a>
	                          	<%}else{ %>
									<span class="gray6">删除</span>
								<%} %>
                        	</td>                          
                        </tr>
                   		<%}}%>
                      </table>
              </div>
              <%QuestionList.rendPagingResult(out, result); %>
              <div class="box2 clearfix"></div>
            </div>
        </div>   
    </div>
   	</form>
   	<%@include file="/WEB-INF/include/left.jsp" %>
   	</div>
   	</div>
<%@include file="/WEB-INF/include/footer.jsp"%>
<%@include file="/WEB-INF/include/script.jsp"%>

<%@include file="/WEB-INF/include/datepicker.jsp"%>
<script type="text/javascript">

	$(function() {
		//获取class为caname的元素
		$(".setpxz").click(function() {
		var td = $(this);
		var txt = td.text();
		var input = $("<input type='text' style='width: 25px;'  value='" + txt + "'/>");
		td.html(input);
		input.click(function() { return false; });
		//获取焦点
		input.trigger("focus");
		//文本框失去焦点后提交内容，重新变为文本
		input.blur(function() {
		var newtxt = $(this).val();
		//判断文本有没有修改
		if (newtxt != txt) {
		td.html(newtxt);
		var caid = $.trim(td.prev().text());
		var url = '<%=controller.getURI(request, UpdateQuestionPxz.class)%>?id=' + caid + '&pxz='+newtxt+'&date=' + new Date();
		$.get(url, function(data) {
		if(data=="1")
		{
		td.html(newtxt);
		}
		});	
		}
		else
		{
		td.html(txt);
		}
		});
		});
		}); 
	
</script>

</body>
</html>